// DICOM 相关类型定义

/**
 * DICOM 元数据接口
 */
export interface DicomMetadata {
  // 患者信息
  patient: {
    name: string;
    id: string;
    birthDate: string;
    sex: string;
  };
  
  // 检查信息
  study: {
    instanceUid: string;
    date: string;
    time: string;
    description: string;
  };
  
  // 序列信息
  series: {
    instanceUid: string;
    number: string;
    description: string;
    modality: string;
  };
  
  // 图像信息
  image: {
    instanceUid: string;
    number: string;
    position: number[];
    orientation: number[];
    pixelSpacing: number[];
    sliceThickness: number;
  };
}

/**
 * DICOM 图像信息接口
 */
export interface DicomImageInfo {
  imageId: string;
  minPixelValue: number;
  maxPixelValue: number;
  slope: number;
  intercept: number;
  windowCenter: number;
  windowWidth: number;
  rows: number;
  columns: number;
  height: number;
  width: number;
  color: boolean;
  sizeInBytes: number;
  metadata: DicomMetadata;
}

/**
 * DICOM 文件信息接口
 */
export interface DicomFileInfo {
  fileName: string;
  size: number;
  lastModified: number;
  contentType: string;
  imageId?: string;
  metadata?: DicomMetadata;
}

/**
 * DICOM 数据源类型
 */
export type DicomDataSource = 
  | { type: 'url'; url: string }
  | { type: 'file'; file: File }
  | { type: 'buffer'; buffer: ArrayBuffer };

/**
 * DICOM 加载状态
 */
export type DicomLoadStatus = 
  | 'idle'
  | 'downloading'
  | 'extracting'
  | 'processing'
  | 'initializing'
  | 'loaded'
  | 'error';

/**
 * DICOM 加载错误类型
 */
export interface DicomLoadError {
  code: string;
  message: string;
  details?: any;
  timestamp: number;
}

/**
 * DICOM 配置接口
 */
export interface DicomConfig {
  // 内存配置
  maxMemoryUsage?: number;
  
  // 缓存配置
  cacheEnabled?: boolean;
  cacheSize?: number;
  
  // Cornerstone 配置
  cornerstone?: {
    renderer?: 'webgl' | 'canvas2d';
    useWebWorkers?: boolean;
    maxWebWorkers?: number;
  };
  
  // 下载配置
  download?: {
    timeout?: number;
    retries?: number;
    concurrent?: number;
  };
  
  // 处理配置
  processing?: {
    enableCompression?: boolean;
    compressionQuality?: number;
    enableMetadataCache?: boolean;
  };
}

/**
 * DICOM 进度信息
 */
export interface DicomProgress {
  stage: DicomLoadStatus;
  progress: number; // 0-100
  message: string;
  timestamp: number;
  data?: any;
}

/**
 * DICOM 事件类型
 */
export type DicomEventType = 
  | 'progress'
  | 'loaded'
  | 'error'
  | 'warning'
  | 'memory-warning';

/**
 * DICOM 事件接口
 */
export interface DicomEvent {
  type: DicomEventType;
  timestamp: number;
  data?: any;
}

/**
 * DICOM 事件处理器类型
 */
export type DicomEventHandler = (event: DicomEvent) => void;
